package net.butfly.bus.filter;

import java.util.Map;

import net.butfly.bus.Request;
import net.butfly.bus.Response;
import net.butfly.bus.util.BusUtils;

public class ExceptionHandleFilter extends FilterBase implements Filter {
	private boolean debugging;

	@Override
	public void initialize(Map<String, String> params) {
		try {
			this.debugging = Boolean.valueOf(params.get("debug"));
		} catch (Throwable th) {
			this.debugging = false;
		}
	}

	@Override
	public void execute(Request request, Response response) {
		try {
			super.execute(request, response);
		} catch (Exception ex) {
			BusUtils.exceptionToError(response, ex, debugging);
		}
	}
}
